<?php

class CanBoQLDeTaiVaSVDK extends BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
        return View::make('canbo.dsdetai')->with('title','Danh sách đề tài luận văn');
	}
        public function index1()
	{
        return View::make('canbo.dssvdk')->with('title','Danh sách sinh viên đăng ký');
	}

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
        return View::make('canboqldetaivasvdks.create');
	}

	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		//
	}

	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show_detai1()
	{
        $array_dsdetai = DB::table('de_tai_luan_van')
        	->join('chi_tiet_can_bo_huong_dan',
        			function($join) 
        			{
                        $join->on('de_tai_luan_van.id','=','chi_tiet_can_bo_huong_dan.id_de_tai');
                	}
                 	)
            ->join('hoc_ky_nien_khoa',
            		function($join) 
        			{
                        $join->on('de_tai_luan_van.id_hoc_ki_nien_khoa','=','hoc_ky_nien_khoa.id');
                	}
                 	)
			->select('de_tai_luan_van.ma_so_de_tai',
					'de_tai_luan_van.ten_de_tai',
					'de_tai_luan_van.mo_ta_de_tai')
			->where('chi_tiet_can_bo_huong_dan.id_can_bo','=',$id,'and')                                
            ->where('hoc_ky_nien_khoa.nien_khoa','=',$nienkhoa,'and')
            ->where('hoc_ky_nien_khoa.hoc_ky','=',$hocky)
			->get();
        return ($array_dsdetai);
	}
	public function show_detai2($id, $nienkhoa, $hocky)
	{
        $array_dsdetai = DB::table('de_tai_luan_van')
        	->join('chi_tiet_can_bo_huong_dan',
        			function($join) 
        			{
                        $join->on('de_tai_luan_van.id','=','chi_tiet_can_bo_huong_dan.id_de_tai');
                	}
                 	)
            ->join('hoc_ky_nien_khoa',
            		function($join) 
        			{
                        $join->on('de_tai_luan_van.id_hoc_ki_nien_khoa','=','hoc_ky_nien_khoa.id');
                	}
                 	)
			->select('de_tai_luan_van.ma_so_de_tai',
					'de_tai_luan_van.ten_de_tai',
					'de_tai_luan_van.mo_ta_de_tai')
			->where('chi_tiet_can_bo_huong_dan.id_can_bo','=',$id,'and')                                
            ->where('hoc_ky_nien_khoa.nien_khoa','=',$nienkhoa,'and')
            ->where('hoc_ky_nien_khoa.hoc_ky','=',$hocky)
			->get();
        return ($array_dsdetai);
	}
	public function show_svdk1($id, $nienkhoa, $hocky)
	{
		$array_dssinhvien = DB::table('de_tai_luan_van')
			->join('chi_tiet_can_bo_huong_dan', 
					function($join)
					{
						$join->on('chi_tiet_can_bo_huong_dan.id_de_tai','=','de_tai_luan_van.id');
					})
			->join('can_bo',
					function($join)
					{
						$join->on('can_bo.id','=','chi_tiet_can_bo_huong_dan.id_can_bo');
					})
			->join('nhom_dang_ki',
					function($join)
					{
						$join->on('nhom_dang_ki.id_de_tai','=','de_tai_luan_van.id');
					})
			->join('sinh_vien',
					function($join)
					{
						$join->on('sinh_vien.id','=','nhom_dang_ki.id_sinh_vien');
					})
			->join('hoc_ky_nien_khoa',
					function($join)
					{
						$join->on('hoc_ky_nien_khoa.id','=','de_tai_luan_van.id_hoc_ki_nien_khoa');
					})							
			->select('de_tai_luan_van.ten_de_tai','sinh_vien.ten','sinh_vien.ho','sinh_vien.mssv')
			->where('can_bo.id','=',$id,'and')
			->where('hoc_ky_nien_khoa.nien_khoa','=',$nienkhoa,'and')
			->where('hoc_ky_nien_khoa.hoc_ky','=',$hocky)
			->get();
		return ($array_dssinhvien);		
	} 
	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
        return View::make('canboqldetaivasvdks.edit');
	}

	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}

	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		
	}
}
